
package org.javaboy.vhr.controller;
import org.javaboy.vhr.model.Employee;
import org.javaboy.vhr.model.RespBean;
import org.javaboy.vhr.model.RespPageBean;
import org.javaboy.vhr.model.Train;
import org.javaboy.vhr.service.TrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/train")
public class TrainController {

   @Autowired
    TrainService trainService;

    @PostMapping("/")
    public RespBean addSalary(@RequestBody Train train) {
        if (trainService.addTrain(train) == 1) {
            return RespBean.ok("新增成功!");
        }
        return RespBean.error("新增失败!");
    }

    @PutMapping("/changeStatus")
    public RespBean changeStatus(@RequestBody Train train ) {
        if (trainService.changeStatus(train) == 1) {
            return RespBean.ok("通过成功!");
        }
        return RespBean.error("通过失败!");
    }

    @GetMapping("/getAllTrain")
    public List<Train> getAllTrain() {
       return trainService.getAllTrain();
    }

    //待审核
    @GetMapping("/getTrain_0")
    public RespPageBean getTrain_0(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "5") Integer size, Integer status_id_1, Integer status_id_2) {
        return trainService.getTrain_0(page,size,status_id_1,status_id_2);
    }








}
